
// MASTER DO-FILE FOR FIGURES
// Hilscher, Raviv, Reis "How likely is an inflation disaster?"
clear

if "$home" == "" {
    local wd = subinstr(c(pwd), "\", "/", .) 
	global home "`wd'"
	
}


*global DataStata "$home/DataforStata//Tables&Plots"
* Go one folder up
* Get parent directory manually
local lastslash = strrpos("$home", "/")   // Find last slash position
global home_parent = substr("$home", 1, `lastslash' - 1)   // Extract parent directory
global input "$home_parent/input"
global figures "$home_parent/Figures"



// OPTION 2: which regions to run for, from {"EZ", "US"}
local regions  "US" "EZ"

local updateIteration "2024_10Oct"


// This sequence of programs create two end dta files:  EZ_allq and EZ_allm, 
//  with all the data then used in paper. Some intermediate datasets are also
//  created, EZ_ZQtails, EZ_ZNtails, EZ_YQtails, EZ_55tailsmonthly, EZ_55tailsquarterly
//  whichcombined would have many more variables
foreach region of local regions {

    disp "`region'"
    
    clear all
    // data & computing
    do "$home/data_ZQtails.do" `region' `updateIteration'
    do "$home/data_ZNtails.do" `region' `updateIteration'
    do "$home/data_YQtails.do" `region' `updateIteration'
    do "$home/data_55tails.do" `region'
    
    // merge
    do "$home/data_mergem.do" `region'
}
do "$home/DATASEs.do"  
clear
graph drop _all




do "$home/figure_estimates-v3.do" //					// only figures that are actially used in new version
foreach region of local regions {
    clear all
    do "$home/figure_dynamics.do" `region' // Model parameter estimates
    do "$home/figure_riskpremia.do" `region' // Risk premia
}
clear
graph drop _all
